package jp.co.brilliantservice.app.openar.view;

import android.graphics.Canvas;
import android.content.Context;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Paint.Style;
import android.util.AttributeSet;
import android.widget.LinearLayout;

public class TransparentPanel extends LinearLayout
{
	private Paint	innerPaint, borderPaint;
	private float mRx = 0;
	private float mRy = 0;

	public TransparentPanel(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	public TransparentPanel(Context context) {
		super(context);
		init();
	}

	private void init() {
		innerPaint = new Paint();
		innerPaint.setARGB(200, 75, 75, 75); //gray
		innerPaint.setAntiAlias(true);

		borderPaint = new Paint();
		borderPaint.setARGB(200, 55, 55, 55);
		borderPaint.setAntiAlias(true);
		borderPaint.setStyle(Style.STROKE);
		borderPaint.setStrokeWidth(2);
	}

	public void setRoundRadius(float rx, float ry) {
		mRx = rx;
		mRy = ry;
	}

	public void setInnerPaint(Paint innerPaint) {
		this.innerPaint = innerPaint;
	}

	public void setBorderPaint(Paint borderPaint) {
		this.borderPaint = borderPaint;
	}

    @Override
    protected void dispatchDraw(Canvas canvas) {
    	RectF drawRect = new RectF();
    	drawRect.set(0,0, getMeasuredWidth(), getMeasuredHeight());

    	if (mRx > 0 || mRy > 0) {
	    	canvas.drawRoundRect(drawRect, mRx, mRy, innerPaint);
//			canvas.drawRoundRect(drawRect, mRx, mRy, borderPaint);
//	    	canvas.drawLine(startX, startY, stopX, stopY, borderPaint);　
//			canvas.drawRoundRect(drawRect, mRx, mRy, borderPaint);
    	} else {
	    	canvas.drawRect(drawRect, innerPaint);
//			canvas.drawRect(drawRect, borderPaint);
    	}

		super.dispatchDraw(canvas);
    }
}